﻿using System;
using System.Runtime.Serialization;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace Reviewer.Entities
{
    [DataContract(Namespace = "Reviewer.Entities")]
    public sealed class News : IExtensibleDataObject
    {
        public static bool operator ==(News item1, News item2)
        {
            // If both are null, or both are same instance, return true.
            if (System.Object.ReferenceEquals(item1, item2))
            {
                return true;
            }

            // If one is null, but not both, return false.
            if (((object)item1 == null) || ((object)item2 == null))
            {
                return false;
            }

            return item1.Equals(item2);
        }
        public static bool operator !=(News item1, News item2)
        {
            return !(item1 == item2);
        }

        [DataMember(IsRequired = true)]
        public int Id { get; set; }
        [DataMember(IsRequired = true)]
        public Guid NewsId { get; set; }
        [DataMember]
        public string Title { get; set; }
        [DataMember]
        public string Header { get; set; }
        [DataMember]
        public string Text { get; set; }
        [DataMember]
        public string Source { get; set; }
        [DataMember]
        public int NewsType { get; set; }
        [DataMember]
        public int Author { get; set; }
        [DataMember]
        public bool ShowRelatedScreenshots { get; set; }
        [DataMember]
        public DateTime NewsDate { get; set; }

        public override bool Equals(object obj)
        {
            News second = obj as News;
            if (second != null)
            {
                return this.Id.Equals(second.Id)
                    && this.NewsId.Equals(second.NewsId)
                    && this.Title.Equals(second.Title)
                    && this.Header.Equals(second.Header)
                    && this.Text.Equals(second.Text)
                    && this.Source.Equals(second.Source)
                    && this.NewsType.Equals(second.NewsType)
                    && this.Author.Equals(second.Author)
                    && this.ShowRelatedScreenshots.Equals(second.ShowRelatedScreenshots)
                    && this.NewsDate.Equals(second.NewsDate);
            }

            return false;
        }

        public override int GetHashCode()
        {
            return this.Id.GetHashCode();
        }


        #region IExtensibleDataObject Members
        ExtensionDataObject IExtensibleDataObject.ExtensionData { get; set; }
        #endregion
    }
}
